﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArchivingDataModel
{
    public partial class AttachmentsVersioning
    {
        public string getImageUrl()
        {
            if (this.MimeType!=null && (this.MimeType.ToLower() == "image/jpeg" || this.MimeType.ToLower() == "image/gif" || this.MimeType.ToLower() == "image/png" || this.MimeType.ToLower() == "image/jpg"))
            {
                return this.Version_Path;
            }
            else
            {
                return "~/images/unknown.png";
            }
        }
        public static string getImageUrl(object versionID)
        {
            long id = Convert.ToInt64(versionID);
            using (ArchivingDataEntities ent = new ArchivingDataEntities())
            {
                return ent.AttachmentsVersionings.FirstOrDefault(i => i.Version_ID == id).getImageUrl();
            }
        }
    }
}
